<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>{$Think.lang.filegl}</title>
	<link rel="stylesheet" href="__ADMIN__/vendor/layui/css/layui.css">
	<script src="__ADMIN__/vendor/iconfont/iconfont.js"></script>
	<style>
		.fileicon i {
			font-size: 1.8em;
			color: #FFE88C;
			-webkit-text-stroke: 1px #F1C95F;
		}

		.layui-table[lay-size="lg"] td,
		.layui-table[lay-size="lg"] th {
			padding: 15px 10px;
		}

		.filelink {
			color: #20A53A;
		}

		.filelink:hover {
			color: #333;
		}

		.cz {
			display: none;
		}

		tr:hover .cz {
			display: block;
		}

		.my-icon {
			width: 1em;
			height: 1em;
			vertical-align: -0.15em;
			fill: currentColor;
			overflow: hidden;
			font-size: 30px;
		}
	</style>
</head>

<body style="padding:15px;">
	<div class="head-top">
		<button class="layui-btn layui-btn-sm layui-btn-primary">
			<i class="layui-icon"><a href="?currdir={$root|iconv='GB2312','UTF-8',###}\..">{$Think.lang.spid}</a></i>
		</button>
		<button class="layui-btn layui-btn-sm layui-btn-primary" id="reload">
			<i class="layui-icon">&#x1002;</i>
		</button>
		<button class="layui-btn layui-btn-sm layui-btn-danger">{$Think.lang.dqlj}：{$root|iconv='GB2312','UTF-8',###}</button>
		<span class="layui-btn layui-btn-sm layui-btn-success" style="float:right;">{$Think.lang.gong}{$num.dir}{$Think.lang.gdir}，{$num.file}{$Think.lang.gfile}</span>
	</div>
	<div class="file-list">
		<table class="layui-table" lay-size="lg" lay-skin="line">
			<thead>
				<tr>
					<th>{$Think.lang.filename}</th>
					<th>{$Think.lang.dsize}</th>
					<th>{$Think.lang.slt}</th>
					<th>{$Think.lang.addtime}</th>
					<th>{$Think.lang.updatetime}</th>
					<th style="text-align:right;width:300px;">{$Think.lang.caoz}</th>
				</tr>
			</thead>
			<tbody>
				{volist name="dirs" id="vo"}
				<tr>
					<td class="fileicon">
						<svg class="my-icon" aria-hidden="true">
							<use xlink:href="{$vo.icon}"></use>
						</svg>
						<a
							href="{$vo.flag?'?currdir='.$vo.currdir:'javascript:;'}">{$vo.name|iconv='GB2312','UTF-8',###}</a>
					</td>
					<td>{$vo.flag?"目录":size_format($vo.size,2)}</td>
					<?php $p=urlencode($vo['currdir']);?>
					<td>{$p|getpics=###,40}</td>
					<td>{$vo.ctime|date="Y-m-d H:i:s",###}</td>
					<td>{$vo.mtime|date="Y-m-d H:i:s",###}</td>
					<td>
						<span class="cz">
							<a class="filelink" href="javascript:;"
								onclick="DeleteFile('{$vo.currdir|urlencode=###}')">{$Think.lang.del}</a> |
								{eq name="vo.flag" value="0"}
								<a class="filelink" href="{:url('file/fileEdit')}?file={$vo.currdir|urlencode=###}" >{$Think.lang.edit}</a> |
								{/eq}
							<a class="filelink" href="javascript:;"
								onclick="ReName('{$vo.currdir|urlencode=###}','{$vo.currdir|basenamecn=###}')">{$Think.lang.rename}</a> |
								{eq name="vo.flag" value="0"}
								<a class="filelink" href="{:url('file/download')}?currdir={$vo.currdir|urlencode=###}">{$Think.lang.down}</a>
								{/eq}
						</span>
					</td>
				</tr>
				{/volist}





			</tbody>
		</table>
		<div class="page" id="page">

		</div>
	</div>

	<script src="__ADMIN__/vendor/js/jquery.js"></script>
	<script src="__ADMIN__/vendor/layui/layui.js"></script>
	<script>
		layui.use(['laypage', 'layer'], function () {
			var laypage = layui.laypage;
			var layer = layui.layer;
			//执行一个laypage实例
			laypage.render({
				elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
				, count: '{$page.count}' //数据总数，从服务端得到
				, limit: '{$page.limit}'
				, curr: '{$page.curr}'
				, jump: function (obj, first) {
					//obj包含了当前分页的所有参数，比如：
					// console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
					// console.log(obj.limit); //得到每页显示的条数

					//首次不执行
					if (!first) {
						<?php $path=iconv('GB2312','UTF-8',$root.DIRECTORY_SEPARATOR);?>
						location.href="?&root={$path|urlencode=###}&page="+obj.curr;
					}
				}
			});
		});
		$(function () {
			$(window.parent.document).find('#righttitle').text($('title').text());
			$('#reload').on('click', function () {
				location.reload();
			})
		})
		$('.edit').on('click', function () {
				var file=$(this).attr('data');
				$.post("{:url('file/edit')}",{file:file},function(res){
					
				})
            });
		// 文件删除操作
		function DeleteFile(file) {
			layer.confirm('确认删除文件或目录吗', { icon: 3, title: '温馨提示' }, function (index) {
				$.post("{:url('file/delfile')}", { file: file }, function (res) {
					if (res.code == 1) {
						layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
							location.reload();
						});
					} else {
						layer.msg(res.msg, { icon: 2, time: 1000 }, function () {
							location.reload();
						});
					}
				});
			});

		}
		// 重命名
		function ReName(file,filename) {
			layer.prompt({
				formType: 2,
				value: filename,
				title: '请输入新的文件名',
				area: ['200px', '20px'] //自定义文本域宽高
			}, function (value, index, elem) {
				$.post("{:url('file/rename')}",{file:file,filename:value},function(res){
					if (res.code == 1) {
						layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
							location.reload();
						});
					} else {
						layer.msg(res.msg, { icon: 2, time: 1000 }, function () {
							location.reload();
						});
					}
				})
			});
		}
	</script>
</body>

</html>